<template>
  <div>
    <!-- 最上面 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>权限管理</el-breadcrumb-item>
      <el-breadcrumb-item>角色列表</el-breadcrumb-item>
    </el-breadcrumb>

    <!-- 卡片视图区域 -->
    <el-card>
      <!-- 添加角色按钮区域 -->
      <el-row>
        <el-col>
          <el-button type="primary">添加角色</el-button>
        </el-col>
      </el-row>
      <!-- 角色列表区域 -->
      <el-table :data="rolesList" stripe border style="width: 100%">
        <!-- 展开列 -->
        <el-table-column type="expand" width="53"></el-table-column>
        <!-- 索引列 -->
        <el-table-column type="index" label="#" width="53"> </el-table-column>
        <el-table-column prop="roleName" label="角色名称" width="327">
        </el-table-column>
        <el-table-column prop="roleDesc" label="角色描述" width="327">
        </el-table-column>
        <el-table-column label="操作" width="327">
          <template lot-scope="scoped">
            <el-row>
              <!-- 编辑按钮 -->
              <el-button type="primary" icon="el-icon-edit" size="mini"
                >编辑</el-button
              >
              <!-- 删除按钮 -->
              <el-button type="danger" icon="el-icon-delete" size="mini"
                >删除</el-button
              >
              <!-- 分配角色按钮(带提示) -->
              <el-tooltip content="分配角色" placement="top" :enterable="false">
                <el-button type="warning" icon="el-icon-s-tools" size="mini"
                  >分配权限</el-button
                >
              </el-tooltip>
            </el-row>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
export default {
  data() {
    return {
      rolesList: []
    };
  },
  created() {
    this.getRolesList();
  },
  methods: {
    async getRolesList() {
      const { data: res } = await this.$http.get("roles");
      if (res.meta.status !== 200) {
        return this.$message.error("获取角色列表失败");
      } else {
        this.rolesList = res.data;
      }
    }
  }
};
</script>

<style lang="less"></style>
